package net.tngou.crawler.service;

import java.util.HashMap;
import java.util.List;

import net.tngou.c4j.tag.Mark;
import net.tngou.crawler.jdbc.OrderType;
import net.tngou.crawler.jdbc.QueryHelper;
import net.tngou.crawler.pojo.Data;
import net.tngou.crawler.pojo.POJO;
import net.tngou.crawler.pojo.Tag;
import net.tngou.crawler.pojo.Tag_data;

public class TagService extends BaseService {

	
	public void updateTag(Tag tag) {
		Data bean = new Data();
		String filter="value like '%"+tag.getName()+"%'";
		List<? extends POJO> list = bean.list(filter, "id", OrderType.ASC);
		if(list!=null&&!list.isEmpty())
		{
			tag.setCount(tag.getCount()+list.size());
			tag.update();
			list.forEach(e->{
				POJO pojo = new Tag_data().get("tag ="+tag.getId()+" AND data="+e.getId());
				if(pojo==null)
				{
					Tag_data tag_data = new Tag_data();
					
					tag_data.setData(e.getId());
					tag_data.setTag(tag.getId());
					tag_data.save();
				}
				
			});
		}
				
	}
}
